package com.crm.util;

import cn.hutool.core.util.ObjectUtil;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.support.RequestContext;

import javax.servlet.http.HttpServletResponse;

/**
 * @author junxian.dou
 * @Package：com.crm.util
 * @Project：springboot-crm
 * @name：HttpContext
 * @Date：2024/12/13 17:47
 * @Filename：HttpContext
 * @verson 1.0.0
 * @desc
 */
public class HttpContext {

    public static HttpServletResponse getResponse(){
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return ObjectUtil.isNull(requestAttributes) ? null : requestAttributes.getResponse();
    }
}
